package app.cn.com.school.activity

import android.databinding.DataBindingUtil
import android.databinding.ViewDataBinding
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.widget.Toast
import app.cn.com.school.tools.Constants

/**
 * Created by Administrator on 2017/10/31 0031.
 */
open abstract class BaseActivity<T : ViewDataBinding> : AppCompatActivity() {

    lateinit var binding: T

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        if (!Constants.isNetworkAvailable(this@BaseActivity)) {
            Toast.makeText(applicationContext, "检查网络！", Toast.LENGTH_LONG).show()
            return
        }
    }

    override fun onResume() {
        super.onResume()
        initBindingVar()
        initTitle()
    }

    fun initBinding(layout: Int) {
        binding = DataBindingUtil.setContentView<T>(this, layout)!!
    }

    fun showTips(content: String) {
        Toast.makeText(this, content, Toast.LENGTH_LONG).show()
    }


    abstract fun initBindingVar()
    abstract fun initTitle()

}


